package org.platform.processor.knowledge;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.platform.constant.ApplyStatusConstant;
import org.platform.mo.csmo.cmd10022.KnowApplyRequestParam;
import org.platform.mo.csmo.common.KB_Main;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 该类主要处理知识审核结果
 *
 * @author FengJie
 * @date 2018/4/21
 */
@Service
@Slf4j
public class KnowledgeAuditReceiveProcessor {
    @Autowired
    private KnowledgeProcessor processor;

    /**
     * 处理知识审核的结果
     * 1.更新审核信息
     * 2.更新子模块信息(如果非空,说明审核通过)
     *
     * @param auditData
     */
    public void knowledgeAudit(String auditData) {
        KnowApplyRequestParam applyBeanParam = JSON.parseObject(auditData, KnowApplyRequestParam.class);
        KB_Main kbMain = applyBeanParam.getKbMain();
        if (ApplyStatusConstant.AUDIT_SUCCESS == kbMain.getStatus()) {
            //更新主表
            processor.renewVersion(kbMain);
            log.info("知识审核通过");
        } else {
            processor.renewStatus(kbMain);
            log.info("知识审核未通过");
        }
    }
}
